home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / QuickDraw™ GX / Programming Stuff / Sample Code / Graphics Samples / One Rectangle ƒ / one rectangle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  3.5 KB  |  112 lines  |  [TEXT/KAHL]

  1. /*
  2.     one rectangle.c
  3.     
  4.     This file contains the calls that an application needs to make for the "graphics shell" to work correctly.
  5.     This "one rectangle" will draw 1 black rectangle ( {0, 0, ff(100), ff(100)} ) in the upper left corner of the window.
  6.     
  7.     NOTES:
  8.     • This file requires the new "GX"-ified interface files and libraries. With the interface files, all types and function
  9.     names are proceeded by a "gx" for types or "GX" for function names.
  10.     
  11.     • This file requires the following files to run correctly:
  12.         "graphics shell .c", "graphics debug library.c", "transform library.c".
  13.         
  14.     • This file prints the "best" in landscape mode.
  15.  
  16.     
  17.     ©1992 - 1994  Apple Computer, Inc.  All rights reserved.
  18. */
  19.  
  20. #include <events.h>
  21. #include <windows.h>
  22.  
  23. #include "graphics libraries.h"
  24. #include "graphics toolbox.h"
  25. #include "graphics shell.h"
  26.  
  27. //
  28. //  Set up the title and size of the window 
  29. //
  30. Str255         gWindowTitle = "\p one rectangle ";
  31. Rect             gWindowQDRect  = {50, 50, 275, 275};
  32.  
  33. //     
  34. //    gGraphicsHeapSize sets the size of the graphics heap created by calling the NewGraphicsClient routine
  35. //    in main () within graphics shell.c.  You can determine the amount of graphics heap required by using GraphicsBug.
  36. //    With  gGraphicsHeapSize set to 25k, I had 2 free blocks left in the graphics heap. Sounds good to me.
  37. //
  38. long            gGraphicsHeapSize = 25;
  39.  
  40. gxShape         gShape;
  41.  
  42.  
  43. /*------ DoInitialization ---------------------------------------------------------------------------------*/
  44. //
  45. //    This function is creates the shape we want to draw on DoDraw
  46. //
  47.  
  48. void DoInitialization(gWindow)
  49. WindowPtr gWindow;
  50. {
  51.     gxRectangle         rectData = {0, 0, ff(100), ff(100)};    
  52.  
  53.     gShape = GXNewRectangle(&rectData); 
  54. }
  55.  
  56.  
  57. /*------ DoDraw ---------------------------------------------------------------------------------------*/
  58. //
  59. //    This function performs all of the drawing by calling GXDrawShape on our global shape - gShape.
  60. //
  61. void DoDraw( gWindow )
  62. WindowPtr gWindow;
  63. {
  64.     GXDrawShape ( gShape );
  65. }
  66.  
  67.  
  68. /*------ DoDispose -------------------------------------------------------------------------------------*/
  69. //
  70. //    This function tosses all of the shapes and the window we have created.
  71. //
  72. void DoDispose( gWindow )
  73. WindowPtr gWindow;
  74. {
  75.     //  
  76.     //    You should always dispose of your QuickDraw GX objects before tossing your window. Why? It's generally good 
  77.     //    form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
  78.     //    call to DisposeWindow should dispose of the objects. If you are running the debugging version of the 
  79.     //    "GXGraphics(debug)" extension with notices enabled, you will receive a notice that you had not disposed of
  80.     //    everything when you app quits. 
  81.     //
  82.     //    Notices are enabled within the "grahics shell.c" automatically, if you have installed the debug
  83.     //    extension. We determine if the debug init is installed by making the appropriate Gestalt call while the
  84.     //    graphics shell is starting up; see the "graphics shell.c" file for details.
  85.     //
  86.     GXDisposeShape( gShape );  
  87.      GXDisposeShape( gWindowBoundsShape );  
  88.         DisposeWindow( gWindow );
  89. }
  90.     
  91.  
  92.  
  93. /*------ DoClick ---------------------------------------------------------------------------------------*/
  94. //
  95. //    This function handles click by the user...
  96. //
  97. void DoClick( orgMouseLoc, theWindow )
  98. gxPoint        orgMouseLoc;
  99. WindowPtr     theWindow;
  100. {
  101. }
  102.  
  103.  
  104. /*------ DoIdle ----------------------------------------------------------------------------------------*/
  105. //
  106. //    This function is called within the event loop when the "graphics shell" receives a null event...
  107. //
  108. void DoIdle(gWindow)
  109. WindowPtr gWindow;
  110. {
  111. }
  112.